package com.xun.controller;

import com.xun.bean.User;
import com.xun.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Package: com.xun.controller
 * @ClassName: UserController
 * @Author: Think
 * @CreateTime: 2021/6/15 16:05
 * @Description:
 */
@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("/listUsers")
    public List<User> listUsers(){
        return userMapper.listUsers();
    }

    @GetMapping("/getUserById/{userId}")
    public List<User> getUserById(@PathVariable String userId){
        return userMapper.getUserById(userId);
    }

    @PostMapping("/addUser")
    public Integer addUser(@RequestBody User user){
        return userMapper.addUser(user);
    }

    @DeleteMapping("/deleteUserById/{userId}")
    public Integer deleteUserById(@PathVariable String userId){
        return userMapper.deleteUserById(userId);
    }

    @PutMapping("/updateUserNameById")
    public Integer updateUserNameById(@RequestBody User user){
        return userMapper.updateUserNameById(user);
    }
}
